package com.linkq.ipinyin.controller;

import com.linkq.ipinyin.model.StudyPlan;
import com.linkq.ipinyin.model.vo.StudyExamVo;
import com.linkq.ipinyin.service.StudyPlanService;
import com.linkq.ipinyin.vo.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @FileName StudyPlanController
 * @Description
 * @Author wangpeng
 * @date 2025-01-11
 **/

@RestController
@RequestMapping("study")
public class StudyPlanController {

    /**
     * 创建学习计划
     */
    @Autowired
    private StudyPlanService studyPlanService;

    @PostMapping("add")
    public ResultInfo add(@RequestBody StudyPlan studyPlan) {
        return studyPlanService.add(studyPlan);
    }

    /**
     * 查询学习计划
     * @param studyPlan
     * @return
     */
    @PostMapping("getStudyPlan")
    public ResultInfo getSTudyPlan(@RequestBody StudyPlan studyPlan) {
        return studyPlanService.getStudyInfo(studyPlan);
    }

    /**
     * 查询某个学习计划的详细信息，包含执行信息
     * @param studyPlan
     * @return
     */
    @PostMapping("getStudyExecution")
    public ResultInfo getStudyExecution(@RequestBody StudyPlan studyPlan) {
        return studyPlanService.getStudyExecution(studyPlan);
    }

    /**
     * 提交某天的学习计划
     * @param studyExamVo
     * @return
     */
    @PostMapping("executePlan")
    public ResultInfo executePlan(@RequestBody StudyExamVo studyExamVo) {
        return studyPlanService.executePlan(studyExamVo);
    }

    @PostMapping("delete")
    public ResultInfo delete(@RequestBody StudyPlan studyPlan) {
        return studyPlanService.delete(studyPlan);
    }
}
